package com.gamecollection.fish.view;

import com.gamecollection.mvc.View;
import com.gamecollection.fish.model.FishModel;
import com.gamecollection.fish.utils.GameUtils;

import java.awt.*;

/**
 * 大鱼吃小鱼游戏视图
 */
public class FishView implements View {
    
    private FishModel model;
    
    public FishView(FishModel model) {
        this.model = model;
    }
    
    @Override
    public void initialize() {
        // 视图初始化
    }
    
    @Override
    public void render(Graphics g) {
        // 绘制背景
        model.getBg().paintSelf(g);
        
        int state = model.getGameState();
        
        switch (state) {
            case FishModel.STATE_NOT_STARTED:
                GameUtils.drawWord(g, "点击开始游戏", Color.WHITE, 80, 700, 500);
                break;
            case FishModel.STATE_PLAYING:
                // 绘制游戏信息
                GameUtils.drawWord(g, "积分" + model.getCount(), Color.ORANGE, 50, 200, 120);
                GameUtils.drawWord(g, "难度" + model.getLevel(), Color.ORANGE, 50, 600, 120);
                GameUtils.drawWord(g, "等级" + model.getCount(), Color.ORANGE, 50, 1000, 120);
                
                // 绘制我方鱼类
                model.getMyFish().paintSelf(g);
                
                // 绘制敌方鱼类
                for (var enamy : model.getEnamyList()) {
                    enamy.paintSelf(g);
                }
                
                // 绘制boss
                if (model.isBoss() && model.getBoss() != null) {
                    model.getBoss().paintSelf(g);
                }
                break;
            case FishModel.STATE_GAME_OVER:
                GameUtils.drawWord(g, "积分" + model.getCount(), Color.ORANGE, 50, 200, 120);
                GameUtils.drawWord(g, "难度" + model.getLevel(), Color.ORANGE, 50, 600, 120);
                GameUtils.drawWord(g, "等级" + model.getCount(), Color.ORANGE, 50, 1000, 120);
                GameUtils.drawWord(g, "失败", Color.RED, 80, 700, 500);
                break;
            case FishModel.STATE_WIN:
                GameUtils.drawWord(g, "积分" + model.getCount(), Color.ORANGE, 50, 200, 120);
                GameUtils.drawWord(g, "难度" + model.getLevel(), Color.ORANGE, 50, 600, 120);
                GameUtils.drawWord(g, "等级" + model.getCount(), Color.ORANGE, 50, 1000, 120);
                GameUtils.drawWord(g, "胜利", Color.GREEN, 80, 700, 500);
                break;
            case FishModel.STATE_PAUSED:
                GameUtils.drawWord(g, "游戏暂停", Color.YELLOW, 80, 700, 500);
                break;
        }
    }
    
    @Override
    public void update() {
        // 视图更新
    }
    
    @Override
    public void show() {
        // 显示视图
    }
    
    @Override
    public void hide() {
        // 隐藏视图
    }
} 